package com.enzoism.springboot.dive.test;

import com.enzoism.springboot.dive.common.StringUtil;
import org.junit.Test;
import org.mockito.ArgumentMatchers;
import org.mockito.Mockito;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;

import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.anyString;

@PrepareForTest({StringUtil.class})
public class PowerMock01StaticClass extends BaseMockitoTest {

    /**
     * 模拟StringUtil中的静态方法
     *
     * @see StringUtil
     */
    @Test
    public void test静态方法模拟() {
        // MOCK
        PowerMockito.mockStatic(StringUtil.class);
        PowerMockito.when(StringUtil.isEmpty(anyString())).thenReturn(true);

        // VERIFY-VALUE
        boolean empty = StringUtil.isEmpty("1111");
        assertEquals(true, empty);

    }
}
